/*
 * PACKAGE NAME: com.jodinfo.outmirror.api.reportinventorysummary.controller
 * FILE    NAME: ReportInventorySummaryDaoImpl.java
 * COPYRIGHT: Copyright(c) © 2016 heroj Company Ltd. All Rights Reserved
 */ 
package com.jodinfo.outmirror.api.reportinventorysummary.controller;

import java.math.BigInteger;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.hero.common.web.context.UserContext;
import com.hero.core.constant.SysConstant;
import com.hero.core.entity.IPlatformUser;
import com.hero.core.entity.ResponseEntity;
import com.jodinfo.outmirror.api.reportinventorysummary.entity.ReportInventorySummaryEntity;
import com.jodinfo.outmirror.api.reportinventorysummary.service.ReportInventorySummaryBizService;



@Controller
@RequestMapping(value = "/ReportInventorySummaryAdmin")
public class ReportInventorySummaryController  {
	
@Resource(name="reportInventorySummaryBizService")
private ReportInventorySummaryBizService ReportInventorySummaryBizService;
/**
*  list数据源
* 
* */
@RequestMapping(value = "/List")
@ResponseBody
public String ReportInventorySummaryList(ReportInventorySummaryEntity ReportInventorySummaryEntity) {
	if(ReportInventorySummaryEntity==null){
		ReportInventorySummaryEntity = new ReportInventorySummaryEntity();
		ReportInventorySummaryEntity.setPageIndex(SysConstant.DEFAULT_PAGEINDEX);
		ReportInventorySummaryEntity.setPageSize(SysConstant.DEFAULT_PAGESIZE);
	}
	ReportInventorySummaryEntity.setCurrentUser(UserContext.getUser());
	if(StringUtils.isEmpty(ReportInventorySummaryEntity.getBranchOrgId()) 
			&& StringUtils.isEmpty(ReportInventorySummaryEntity.getOfficeOrgId())){
		ReportInventorySummaryEntity.setBranchOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());
		ReportInventorySummaryEntity.setOfficeOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());
	}
	String str = ReportInventorySummaryBizService.queryListForPageReportInventorySummary(ReportInventorySummaryEntity);
	return str;
}
/**
* ReportInventorySummaryEntity List页面
* 
* */
@RequestMapping(value = "/ListPage")
public ModelAndView ReportInventorySummaryListPage(ReportInventorySummaryEntity ReportInventorySummaryEntity,HttpServletRequest request) {
	
	return new ModelAndView(returnPath("ReportInventorySummaryList"));
}
/**
* ReportInventorySummaryEntity详细页 
* 
* */
@RequestMapping(value = "/EditPage")
public ModelAndView ReportInventorySummaryEditPage(ReportInventorySummaryEntity ReportInventorySummaryEntity) {
	
	return new ModelAndView(returnPath("ReportInventorySummaryAdd"));
}
/**
 * 查询ReportInventorySummaryEntity
 * 
 * */
@RequestMapping(value = "/queryByID")
public @ResponseBody String findReportInventorySummaryData(HttpServletRequest request) {
	String id = request.getParameter("id");
	ReportInventorySummaryEntity ReportInventorySummaryEntity =  ReportInventorySummaryBizService.queryById(new BigInteger(id));
	return JSON.toJSONString(ReportInventorySummaryEntity); 
}

/**
 * 保存或更新ReportInventorySummary 
 * 
 * */
@RequestMapping(value = "/saveReportInventorySummary")
public @ResponseBody String saveReportInventorySummaryData(@RequestBody ReportInventorySummaryEntity ReportInventorySummaryEntity) {
	ResponseEntity rs = null;
	if(ReportInventorySummaryEntity!=null){
		ReportInventorySummaryEntity.setCurrentUser(UserContext.getUser());
		if(ReportInventorySummaryEntity.getId()!=null){
			rs = ReportInventorySummaryBizService.updateReportInventorySummary(ReportInventorySummaryEntity);
		}else{
			rs = ReportInventorySummaryBizService.addReportInventorySummary(ReportInventorySummaryEntity);
		}
	}
	return JSON.toJSONString(rs);
}
/**
 * 导出ReportInventorySummaryEntity
 * @author weiwei
 * @date 2015-7-09  下午2:13:28
 * @return
 */
@RequestMapping(value = "/exportReportInventorySummaryExcel")
public void exportReportInventorySummaryExcel(ReportInventorySummaryEntity ReportInventorySummaryEntity,HttpServletResponse response) {
	if(ReportInventorySummaryEntity==null) ReportInventorySummaryEntity = new ReportInventorySummaryEntity();
	ReportInventorySummaryEntity.setCurrentUser(UserContext.getUser());
	if(StringUtils.isEmpty(ReportInventorySummaryEntity.getBranchOrgId()) 
			&& StringUtils.isEmpty(ReportInventorySummaryEntity.getOfficeOrgId())){
		ReportInventorySummaryEntity.setBranchOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());
		ReportInventorySummaryEntity.setOfficeOrgId(((IPlatformUser)UserContext.getUser()).getOrgId());
	}
	ReportInventorySummaryBizService.exportReportInventorySummary(ReportInventorySummaryEntity, response);
}


 /**
 * 
 * 批量删除
 * @author weiwei
 * @date 2017年3月13日 下午2:48:57
 * @param ReportInventorySummaryEntity
 * @return
 */
@RequestMapping(value = "/batchDelReportInventorySummary")
public @ResponseBody String batchDelReportInventorySummary(ReportInventorySummaryEntity ReportInventorySummaryEntity) {
	ResponseEntity rs = null;
	rs = ReportInventorySummaryBizService.batchDelReportInventorySummary(ReportInventorySummaryEntity);
	return  JSON.toJSONString(rs);
}
/**
 * 定义
 * 
 */
private final String MODULE_PATH = "/reportinventorysummary/";

//返回路径
private String returnPath(String jspName) {
	return MODULE_PATH + jspName;
}
}
